<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="title-card">
    <h1>广告图列表</h1>
</div>
<div class="search-card">
    <form id="searchForm" data-search="posterList()">
        <input type="hidden" id="pageNo" name="pageNo" value="${poster.pageNo}">
        <input type="text" class="wpx200 sm" placeholder="广告图名称" name="name" value="${posterQuery.name}">
        <input type="button" value="搜索" id="searchBtn" class="sm">
    </form>
</div>
<div class="fun-card f-clear">
    <input type="button" value="新建" id="posterAdd" class="sm">
</div>
<div class="content-card">
    <table>
        <tr>
            <th>编号</th>
            <th>名称</th>
            <th>链接</th>
            <th>操作</th>
        </tr>
        <c:if test="${empty pagination.list}">
            <tr>
                <td colspan="4" class="explain-text">暂无数据</td>
            </tr>
        </c:if>
        <c:forEach var="poster" items="${pagination.list}">
            <tr>
                <td>${poster.id}</td>
                <td>${poster.name}</td>
                <td>${poster.link}</td>
                <td>
                    <input type="button" class="xs posterUpd" value="修改" data-id="${poster.id}">
                    <input type="button" class="xs posterDel" value="删除" data-id="${poster.id}">
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
<div class="page-card">
    <c:forEach items="${pagination.pageView }" var="page">
        ${page }
    </c:forEach>
</div>
<script>
    $("#posterAdd").on("click", function () {
        posterAdd();
    });
    $(".posterUpd").on("click", function () {
        var id = $(this).data("id");
        posterUpd(id);
    });
    $(".posterDel").on("click", function () {
        var id = $(this).data("id");
        ajaxPosterDel(id);
    });
    $("#searchBtn").on("click", function () {
        posterList();
    });
</script>